package com.xmy.cultivate.controller;

import com.xmy.cultivate.characteristic.ALiYunSmsCharacteristic;
import com.xmy.cultivate.constants.AliyunCodeConstants;
import com.xmy.cultivate.service.IAliyunApiService;
import com.xmy.cultivate.util.Code;
import com.xmy.cultivate.util.CommonUtil;
import com.xmy.cultivate.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.concurrent.TimeUnit;

/**
 * 验证码
 */
@RestController
@RequestMapping("/api/aliMsgCode")
@Scope("prototype")
@Slf4j
public class AliMsgCodeController extends BaseController {

    @Value("${aliyun.tts.accessKeyId}")
    private String accessKeyId;

    @Value("${aliyun.tts.accessKeySecret}")
    private String accessKeySecret;

    @Autowired
    IAliyunApiService iAliyunApiService;

    @Autowired
    RedisTemplate<Object, Object> redisTemplate;

    /**
     * 发送创建试听学员验证码
     * @param phone
     * @return
     */
    @GetMapping("/sendVerifyCode")
    public Result sendVerifyCode(@RequestParam("phone") String phone){

        iAliyunApiService.sendVerifyCode(phone,this.adminId);

        return new Result(Code.OK,"","验证码发送成功，有效时间5分钟");

    }
}
